import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-10-05
 * Time: 11:25
 */
public class Stack_Queue {

    Stack<Integer> s1; // 入队操作栈
    Stack<Integer> s2; // 出队操作栈

    public Stack_Queue() {
        s1 = new Stack<>();
        s2 = new Stack<>();
    }

    //入队
    public void push(int x) {
        s1.push(x);
    }

    //出队
    public int pop() {
        if(empty()) {
            return -1;
        }
        if(s2.isEmpty()) {
            while(!s1.isEmpty()) {
                s2.push(s1.pop());
            }
        }
        return s2.pop();
    }

    public int peek() {
        if(empty()) {
            return -1;
        }
        if(s2.isEmpty()) {
            while(!s1.isEmpty()) {
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    public boolean empty() {
        return s1.isEmpty() && s2.isEmpty();
    }
}
